package oo;

public class Student {
    private String studentId;
    private String studentName;
    private String gender;
    private Course selectedCourse; // 所选课程，初始为null

    // 构造方法
    public Student(String studentId, String studentName, String gender) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.gender = gender;
        this.selectedCourse = null;
    }

    // 选课方法
    public void selectCourse(Course course) {
        this.selectedCourse = course;
        System.out.println("学生" + studentName + "选择了课程" + course.getCourseName());
    }

    // 退课方法
    public void dropCourse() {
        if (selectedCourse != null) {
            System.out.println("学生" + studentName + "退选了课程" + selectedCourse.getCourseName());
            selectedCourse = null;
        } else {
            System.out.println("学生" + studentName + "暂无课程可退选");
        }
    }

    // 打印课表方法
    public void printSchedule() {
        if (selectedCourse == null) {
            System.out.println("暂无选课记录");
        } else {
            System.out.println("课程编号：" + selectedCourse.getCourseId() + 
                               "，课程名称：" + selectedCourse.getCourseName() + 
                               "，上课地点：" + selectedCourse.getClassroom() + 
                               "，时间：" + selectedCourse.getTime() + 
                               "，授课教师编号：" + selectedCourse.getTeacherId());
        }
    }

    // getter方法（可选，根据需要添加）
    public String getStudentName() {
        return studentName;
    }

    public Course getSelectedCourse() {
        return selectedCourse;
    }
}